<?php
include 'includes/session_start.php';
?>

<html>
    <!-- HEADER -->
    <?php
    include 'includes/header.inc.php';
    ?>
    <head>
        <!--Falls eingelogt= weiterleiten auf Quiz -->
        <?php
        include 'includes/session_true_link.php';
        ?>
    </head>

    <body onload="countdown()">

        <!-- Datenbank -->
        <?php include 'includes/db_connect.inc.php'; ?>

        <!-- NAVIGATION -->


        <!-- CONTENT-->


        <div class="site-wrapper">
            <div class="site-wrapper-inner">
                <div class="cover-container">
                    <div class="inner cover">
                        <h1 class="cover-heading">BSR Startup 2014 Quiz</h1>
                        <?php
                        if ($verhalten == 0) {
                            ?>                       
                            <p class="lead">Wir wollen dich!</p>
                            <form role="form" method="post" action="index.php?page=log">
                                <div class="form-group">
                                    <label for="exampleInputEmail1">Email Addresse</label>
                                    <input type="email" class="form-control" name="user" placeholder="Enter email">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">Passwort</label>
                                    <input type="password" class="form-control" name="passwort" placeholder="Passwort">
                                </div>
                                <button type="submit" class="btn btn-default">Einloggen</button>
                            </form>
                            <?php
                        }
                        if ($verhalten == 1) {
                            $AEmail = $_SESSION["username"];
                            $AVorname = "SELECT Vorname FROM quizUser WHERE Email = '$AEmail'";
                            $EVorname = mysql_query($AVorname);

                            while ($row = mysql_fetch_object($EVorname)) {
                                ?>
                                <h1>Hallo <?php echo "$row->Vorname"; ?></h1> Du wirst gleich zum Quiz weiter geleitet 

                                <br>
                                <?php
                            }

                            $ELoginCounter = mysql_query("SELECT LoginCounter FROM quizUser WHERE Email = '$AEmail'");
                            while ($row = mysql_fetch_object($ELoginCounter)) {

                                $Logincounter = "$row->LoginCounter" + 1;
                            }
                            $aendern = "UPDATE quizUser SET LoginCounter ='$Logincounter' WHERE Email = '$AEmail'";
                            $update = mysql_query($aendern);
                        }

                        if ($verhalten == 2) {
                            ?>
                            Du hast dich nicht richtig eingeloggt, <a href="index.php">zurück</a>

                            <?php
                        }
                        ?>    

                        <br>
                        <form name="countdownform">
                            <p>
                                <input type="button" class="btn-danger" disabled="disabled" name="countdowninput" >
                            </p>
                        </form>
                        <br>
                    </div>
                    <div class="mastfoot">
                        <div class="inner">
                            <p>a FSX-Projekt production powered by Lex & Nyhsel</p>
                            <?php
                            if ($verhalten == 1) {
                                ?>
                                <br> <a href="logout.php">Logout</a><br>
                            <?php }
                            ?>
                        </div>
                    </div>     
                </div>
            </div>
        </div>
        <?php
        include 'includes/footer.inc.php';
        ?>
    </body>   
</html>